package com.linkage.educloud.ah.view.activity.app;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;

import com.jcodecraeer.xrecyclerview.ProgressStyle;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.linkage.educloud.ah.R;
import com.linkage.educloud.ah.adapter.BrandAreaAdapter;
import com.linkage.educloud.ah.bean.BrandAreaBean;
import com.linkage.educloud.ah.mvp.contract.IBrandAreaContract;
import com.linkage.educloud.ah.mvp.presenter.BrandAreaPresenter;
import com.linkage.educloud.ah.view.BasicTitleActivity;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Mr'Tang on 2018/12/19.
 */

public class BrandAreaActivity extends BasicTitleActivity implements IBrandAreaContract.IView {

    @BindView(R.id.common_recylerview)
    XRecyclerView common_recylerview;

    IBrandAreaContract.IPresenter iPresenter;
    BrandAreaAdapter adapter;
    List<BrandAreaBean> mlist;

    public static void launch(Context context) {
        Intent intent = new Intent(context, BrandAreaActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.common_one_list;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        iPresenter = new BrandAreaPresenter(this, this);
        setTitle("品牌专区");
        initRecylerview();
        iPresenter.getBrands();
    }

    private void initRecylerview() {
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        common_recylerview.setLayoutManager(layoutManager);
        common_recylerview.setItemAnimator(new DefaultItemAnimator());
        common_recylerview.setLoadingMoreEnabled(false);
        common_recylerview.setPullRefreshEnabled(false);
        adapter = new BrandAreaAdapter(this, mlist);
        common_recylerview.setAdapter(adapter);
    }

    public void initRecylerviewDate(List<BrandAreaBean> mlist) {
        adapter.addAll(mlist);
    }
}
